<template>
  <Form
    ref="productListForm"
    :model="form"
    :rules="rules"
    @keydown.enter.native="handleSubmit"
    inline
    :label-width="80">
    <FormItem prop="name" style="width: 250px" label="商品名称：">
      <!-- <DatePicker v-model="row.probation" format="yyyy-MM-dd" type="daterange" placeholder="请输入试用期" @on-change="handleChange"></DatePicker> -->
      <Input type="text" v-model="form.name" placeholder="请输入商品名称" />
    </FormItem>
    <FormItem style="float: right">
      <Button @click="handleSubmit" icon="md-search" type="primary">
        搜索
      </Button>
    </FormItem>
  </Form>
</template>
<script>
export default {
  name: 'ProductListForm',
  props: {
    nameRules: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      form: {
        name: ''
      }
    }
  },
  computed: {
    rules () {
      return {
        name: this.nameRules
      }
    }
  },
  methods: {
    handleSubmit () {
      this.$refs.productListForm.validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            name: this.form.name
          })
        }
      })
    }
  }
}
</script>
